﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Redmine.Laptop.Common.Core
{
    public class DatePeriod : IEnumerable<DateTime>
    {
        public DateTime Start { get; private set; }
        public DateTime End { get; private set; }

        public DatePeriod(DateTime start, DateTime end)
        {
            Start = start;
            End = end;
        }

        public IEnumerator<DateTime> GetEnumerator()
        {
            var date = Start;
            while (date <= End)
            {
                yield return date;
                date = date.AddDays(1);
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}
